<template>
	<el-main>
		<el-empty v-if="list.length==0" description="暂无投票信息" :image-size="80"></el-empty>
		<el-row :gutter="15">
			<el-col :xl="6" :lg="6" :md="8" :sm="12" :xs="24" v-for="item in list" :key="item.taskId">
				<el-card class="task task-item" shadow="hover" @click="toVote(item)">
					<h2 class="title">{{ item.title }}</h2>
					<ul>
						<li>
							<div class="info-title">时间:{{item.beginTime}}~{{item.endTime}}</div>
						</li>
						<li>
							<div class="info-title" :title="item.subheading">{{ item.subheading }}</div>
						</li>
					</ul>
					<div class="bottom">
						<div class="state">
							<el-tag size="small" type="success">{{item.voteTypeName}}</el-tag>
						</div>
						<div class="handler">
							<el-tag size="small" type="info">{{item.sendDeptName}}</el-tag>
						</div>
					</div>
				</el-card>
			</el-col>
		</el-row>
	</el-main>
<votedialog  v-if="dialog.detailsSave" ref="voteDialog" @success="handleSaveSuccess" @closed="dialog.detailsSave=false"></votedialog>
</template>
<script>
import Votedialog from "@/views/info/vote/votedialog";
export default {
	name: 'My Vote',
	components: {
		Votedialog
	},
	provide() {
		return {
			list: this.list
		}
	},
	data() {
		return {
			dialog: {
				save: false,
				detailsSave:false
			},
			list: []
		}
	},
	mounted() {
		this.getMyVoteListForVote();
	},
	methods: {
		toVote(item)
		{
			this.dialog.detailsSave = true
			this.$nextTick(() => {
				this.$refs.voteDialog.open().setData(item)
			})
		},
		async getMyVoteListForVote() {
			var res = await this.$API.info.vote.getMyVoteListForVote.get();
			if(res.code==200)
			{
				if(res.data){
					this.list = res.data;
				}
			}
		},
		//本地更新数据
		handleSaveSuccess() {
			this.getMyVoteListForVote();
		}
	}
}
</script>

<style scoped>
.task {
	height: 150px;
}
.task-item{
	background: linear-gradient(to right, #79bbff, #95d475);
	color: #fff;
	cursor: pointer;
}
.title{
	width: 100%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	cursor: pointer;
}

.task-item h2 {
	font-size: 15px;
	color: #3c4a54;
	padding-bottom: 15px;
}

.task-item li {
	list-style-type: none;
	margin-bottom: 10px;
}

.task-item li h4 {
	font-size: 12px;
	font-weight: normal;
	color: #999;
}

.task-item li p {
	margin-top: 5px;
}

.task-item .bottom {
	border-top: 1px solid #EBEEF5;
	text-align: right;
	padding-top: 10px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.task-add i {
	font-size: 30px;
}

.task-add p {
	font-size: 12px;
	margin-top: 20px;
}

.dark .task-item .bottom {
	border-color: var(--el-border-color-light);
}

.info-title {
	width: 100%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	cursor: pointer;
}
</style>
